

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import play.db.DB;
import play.jobs.Job;
import play.jobs.OnApplicationStart;


//@OnApplicationStart
public class OnAppStart extends Job {

	@Override
	public void doJob() throws FileNotFoundException {

		try {
			String query = null;

			DB.execute("INSERT INTO `User` (id, email, name, password) VALUES (1,NULL,'anonymous','asd');");
//			DB.execute("INSERT INTO `artist_credit` (id, name,popis,image) VALUES (202,'Hans Zimmer',NULL,NULL);");
//			DB.execute("INSERT INTO `label` (id, name,image) VALUES (4,'Rhino',NULL),(25,'Elektra',NULL),(39,'Varèse Sarabande',NULL),(56,'Warner Bros. Records',NULL),(68,'Reprise Records',NULL),(303,'EMI Records',NULL),(467,'RCA Records',NULL),(764,'Decca',NULL),(1018,'Hollywood Records',NULL),(1020,'ANTI-',NULL),(1088,'Virgin Schallplatten GmbH',NULL),(1180,'DreamWorks Records',NULL),(1502,'Narada Productions',NULL),(1546,'Sony Classical',NULL),(1547,'Walt Disney Records',NULL),(1553,'Silva Screen Records',NULL),(1858,'Colosseum',NULL),(2712,'RCA Victor',NULL),(6864,'La-La Land Records',NULL),(14547,'EMI-Capitol Special Markets',NULL),(15472,'Sony Music Japan International Inc.',NULL),(15857,'Polydor',NULL),(18485,'Perseverance Records',NULL),(27863,'Dundee',NULL),(45209,'Activision',NULL),(46134,'WaterTower Music',NULL),(52706,'Milan',NULL);");
//
//			query = new Scanner(new File("rel.sql")).useDelimiter("\\A").next();
//			DB.execute(query);
//			query = new Scanner(new File("release_label.sql")).useDelimiter("\\A").next();
//			DB.execute(query);
//			query = new Scanner(new File("tracklist.sql")).useDelimiter("\\A").next();
//			DB.execute(query);
//			query = new Scanner(new File("track.sql")).useDelimiter("\\A").next();
//			DB.execute(query);
//			query = new Scanner(new File("medium.sql")).useDelimiter("\\A").next();
//			DB.execute(query);
			BufferedReader reader = new BufferedReader(new FileReader("db/minidb.sql"));
			while (reader.ready()) {
				query = reader.readLine();
				DB.execute(query);
			}

		} catch (IOException ex) {
			Logger.getLogger(OnAppStart.class.getName()).log(Level.SEVERE, null, ex);
		}
	}
}
